﻿using System;
using System.Collections.Generic;
using System.Text;

using Daybreak.Core.Network;
using Daybreak.Core.Network.Udp;

namespace TestUserPacket
{
    public class UserPack : NetPacket
    {
        public override void ServerAction(ref NetBase server)
        {
            UdpNetServer w = (UdpNetServer)server;
            Console.WriteLine("UserPack:ServerAction::" + this.Data);

            this.Data = Encoding.ASCII.GetBytes("reply");
            w.Send(this);
        }

        public override void ClientAction(ref NetBase client)
        {
            Console.WriteLine("UserPack:ClientAction::" + this.Data);
        }
    }

    public class Tewst : NetPacket
    {

        public override void ClientAction(ref NetBase client)
        {
        }

        public override void ServerAction(ref NetBase server)
        {
            Console.WriteLine("Tewst:ServerAction::" + this.Data);
        }
    }

    public class Message : NetPacket
    {

        public override void ClientAction(ref NetBase client)
        {
            Console.WriteLine(Encoding.Unicode.GetString(this.Data));
        }

        public override void ServerAction(ref NetBase server)
        {
            ((UdpNetServer)server).SendToAll(this);
        }
    }
}
